<?PHP
/* $Id: viewchar.php 7 2009-03-24 20:25:52Z ronan $ */

session_start();
//getting the user's access to see if they are allowed
include("includes/paxsql.php");
mysql_close();

include 'includes/database.php';
include 'includes/library.php';

function viewChar() {
	$query = "SELECT * FROM characters WHERE charID = '".addslashes($_GET['id'])."'";
	$results = mysql_query($query);
	
	$char = mysql_fetch_array($results);
	
	$timePassed = eveTime() - $char['lastSeen'];
	$joined = date("M j, Y", $char['joined']);
	$joinedPassed = round((eveTime() - $char['joined'])/86400, 2);
	
	echo "<h1>{$char['name']}</h1><hr>";
	
	echo "<table class=\"cleanTable\">";
	echo "Joined {$joined} ({$joinedPassed} days ago)<br>";
	if ($timePassed < 3600) echo "Last seen " . round($timePassed/60) . " mins ago.";
	else if ($timePassed < 172800) echo "Last seen " . round($timePassed/3600, 2) . " hrs ago.";
	else echo "Last seen " . round($timePassed/86400, 2) . " days ago.";
	if ($char['inactive'] == 1) echo " Character is inactive.";
	
	echo "<br><br>";

	//echo "To see TGRAD forum activity, <a href=\"http://forum.tgrads.com/search.php?keywords=&terms=all&author={$char['name']}&sc=1&sf=all&sk=t&sd=d&sr=posts&st=0&ch=300&t=0&submit=Search\" target=\"_blank\">click here</a>.<br>";
	//echo "To see RAWR forum activity, click here.<br>";
	//echo "To see RAWR killboard activity, click here.<br>";
}

if($access > 1)
{
echo("
<html>
<head>
<link rel='stylesheet' type='text/css' href='main.css'>
<title>snowflake</title>");

include('includes/javascript.php');
echo("
</head>

<body>

<div id='isAltWin' style='display: none;'></div>

<div id='wrapper'>

	<div id='header'><a href='/'>snowflake</a></div>

	<div id='navi'>");

include('includes/navi.php');
echo("</div>

	<div id='main'>");

viewChar();
echo("
	</div>
	
</div>

</body>

</html>");
}
//they do not belong here, they get the boot
else
{
	header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
}
?>
